package com.hodgepodge.commons.base.entity;

import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hodgepodge.commons.validator.annotation.FixedNumValues;
import com.hodgepodge.commons.validator.group.Insert;
import com.hodgepodge.commons.validator.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * title BaseEntity
 * projectName colorful-blog
 * desc Entity基类
 *
 * @author jiangjian
 * @date 2021/6/2 16:27
 */
@Getter
@Setter
public class SuperEntity<T extends Model<?>> extends Model<T> {

    private static final long serialVersionUID = -4720714230294955519L;

    /**
     * 逻辑删除
     * 1:删除
     * 0:未删除
     */
    @ApiModelProperty(value = "逻辑删除(0:未删除 1:已删除)")
    @FixedNumValues(values = {0, 1}, message = "逻辑删除只能传入0或1", groups = {Insert.class, Update.class})
    @TableLogic
    private Integer logicDel;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

}
